package cn.cqie.attendance.manager.controller;

import cn.cqie.attendance.common.util.Page;
import cn.cqie.attendance.common.util.PageBean;
import cn.cqie.attendance.manager.pojo.AdminTeacher;
import cn.cqie.attendance.manager.service.AdminTeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author 697
 * @date 2021/6/16 11:04
 */
@RestController
@Api(tags = "管理员端-教师信息管理模块")
@RequestMapping("/admin/teacher")
public class AdminTeacherController {
    @Autowired
    private AdminTeacherService adminTeacherService;

    /**
     * 模糊条件查询所有教师信息
     * @param teacherName 老师名
     * @param jobNumber 工号
     * @param phone 手机号
     * @param status 状态0无效1有效
     * @param identity 身份证
     * @param pageSize 每一页的数量
     * @param pageNum 当前页
     * @return
     */
    @GetMapping("/queryAllTeacherInfo")
    @ApiOperation("模糊条件查询所有教师信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teacherName", value = "老师名(刘阳)", required = false),
            @ApiImplicitParam(name = "jobNumber", value = "工号(123456)", required = false),
            @ApiImplicitParam(name = "phone", value = "密码(13628437629)", required = false),
            @ApiImplicitParam(name = "status", value = "密码(状态0无效1有效)", required = false),
            @ApiImplicitParam(name = "identity", value = "身份证(5002291235652588)", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每一页的数量(10)", required = false),
            @ApiImplicitParam(name = "pageNum", value = "当前页(1)", required = false)})
    public PageBean<AdminTeacher> queryTeacherInfo(String teacherName, String jobNumber, String phone, String status, String identity, Integer pageSize, Integer pageNum){
       return adminTeacherService.queryAllTeacherInfo(teacherName,jobNumber,phone,status,identity,pageSize,pageNum);
    }



    /**
     * 新增教师信息
     * @param teacherName 老师名
     * @param jobNumber 工号
     * @param identity 身份证
     * @param gender 性别0女1男
     * @param phone 手机号
     * @param positionId 职位
     * @return
     */
    @PostMapping("/insertTeacherInfo")
    @ApiOperation("新增教师信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teacherName", value = "老师名(刘阳)", required = true),
            @ApiImplicitParam(name = "jobNumber", value = "工号(123456)", required = true),
            @ApiImplicitParam(name = "identity", value = "身份证(500229169521542)", required = true),
            @ApiImplicitParam(name = "gender", value = "性别0女1男(1)", required = true),
            @ApiImplicitParam(name = "phone", value = "手机号(13628437629)", required = true),
            @ApiImplicitParam(name = "positionId", value = "职位(1教授2教师3实验员4主任)", required = true)})
    public Page insertAllTeacherInfo(String teacherName, String jobNumber, String identity, Integer gender, String phone, Integer positionId){
        return adminTeacherService.insertAllTeacherInfo(teacherName,jobNumber,identity,gender,phone,positionId);
    }



    /**
     * 根据教师ID修改教师信息
     * @param teacherName 老师名
     * @param jobNumber 工号
     * @param identity 身份证
     * @param gender 性别0女1男
     * @param phone 手机号
     * @param positionId 职位
     */
    @PostMapping("/updateTeacherById")
    @ApiOperation("根据教师ID修改教师信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "teacherName", value = "老师名(刘阳)", required = true),
            @ApiImplicitParam(name = "jobNumber", value = "工号(123456)", required = true),
            @ApiImplicitParam(name = "identity", value = "身份证(500229169521542)", required = true),
            @ApiImplicitParam(name = "gender", value = "性别0女1男(1)", required = true),
            @ApiImplicitParam(name = "phone", value = "手机号(13628437629)", required = true),
            @ApiImplicitParam(name = "positionId", value = "职位(1教授2教师3实验员4主任)", required = true),
            @ApiImplicitParam(name = "id", value = "教师id(1)", required = true),})
    public Page updateTeacherById(String teacherName, String jobNumber, String identity, Integer gender, String phone, Integer positionId,Integer id){
        return adminTeacherService.updateTeacherById(teacherName,jobNumber,identity,gender,phone,positionId,id);
    }


    /**
     * 根据教师ID停用/启用教师
     * @param id
     * @Param 状态
     * @return
     */
    @PostMapping("/changeTeacherById")
    @ApiOperation("根据教师ID停用/启用教师")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "status", value = "状态(0无效1有效)", required = true),
            @ApiImplicitParam(name = "id", value = "教师id(1)", required = true),})
    public Page changeTeacherById(Integer id,Integer status){
        return adminTeacherService.changeTeacherrById(id,status);
    }


    /**
     * 根据教师id删除教师  可批量删除
     * @param teacherIdList
     * @return
     */
    @PostMapping("/deleteTeacherById")
    @ApiOperation("根据教师id删除教师")
    public Page deleteTeacherById(@RequestBody List<Integer> teacherIdList){
        return adminTeacherService.deleteTeacherById(teacherIdList);
    }


}
